package sudroid.android.graphics;

import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.text.TextUtils;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import sudroid.AssertUtil;
import sudroid.LogUtils;
import sudroid.android.CleanUtils;
import sudroid.android.FileUtil;

public class BitmapUtils
{
  public static void compressToFile(File paramFile, Bitmap paramBitmap, Bitmap.CompressFormat paramCompressFormat)
  {
    try
    {
      AssertUtil.checkNull(paramFile);
      if ((paramBitmap != null) && (!paramBitmap.isRecycled()));
      int j;
      for (int i = 1; ; j = 0)
      {
        AssertUtil.check(i);
        AssertUtil.checkNull(paramCompressFormat);
        FileUtil.createNewFile(paramFile);
        FileOutputStream localFileOutputStream = FileUtil.getFileOutputStream(paramFile);
        BufferedOutputStream localBufferedOutputStream = new BufferedOutputStream(localFileOutputStream);
        boolean bool = paramBitmap.compress(paramCompressFormat, 100, localBufferedOutputStream);
        localBufferedOutputStream.close();
        return;
      }
    }
    catch (IOException localIOException)
    {
      while (true)
        LogUtils.e(localIOException);
    }
  }

  public static void compressToFile(String paramString, Bitmap paramBitmap, Bitmap.CompressFormat paramCompressFormat)
  {
    compressToFile(new File(paramString), paramBitmap, paramCompressFormat);
  }

  public static void compressToFileWithRecycle(File paramFile, Bitmap paramBitmap, Bitmap.CompressFormat paramCompressFormat)
  {
    compressToFile(paramFile, paramBitmap, paramCompressFormat);
    paramBitmap.recycle();
  }

  public static void compressToFileWithRecycle(String paramString, Bitmap paramBitmap, Bitmap.CompressFormat paramCompressFormat)
  {
    compressToFileWithRecycle(new File(paramString), paramBitmap, paramCompressFormat);
  }

  public static Bitmap create180RotatedBitmap(Bitmap paramBitmap, Bitmap.Config paramConfig)
  {
    Matrix localMatrix = new Matrix();
    boolean bool = localMatrix.postRotate(180.0F);
    int i = paramBitmap.getWidth();
    int j = paramBitmap.getHeight();
    Bitmap localBitmap = paramBitmap;
    int k = 0;
    return Bitmap.createBitmap(localBitmap, 0, k, i, j, localMatrix, 1);
  }

  public static boolean create180RotatedBitmap(File paramFile, Bitmap.Config paramConfig)
  {
    AssertUtil.checkNull(paramFile);
    AssertUtil.checkNull(paramConfig);
    try
    {
      InputStream localInputStream = FileUtil.makeInputBuffered(new FileInputStream(paramFile));
      Bitmap localBitmap1 = BitmapFactory.decodeStream(localInputStream);
      localInputStream.close();
      if (localBitmap1 != null)
      {
        Bitmap localBitmap2 = create180RotatedBitmap(localBitmap1, paramConfig);
        FileUtil.createNewFile(paramFile);
        OutputStream localOutputStream = FileUtil.makeOutputBuffered(new FileOutputStream(paramFile));
        Bitmap.CompressFormat localCompressFormat = Bitmap.CompressFormat.JPEG;
        boolean bool = localBitmap2.compress(localCompressFormat, 100, localOutputStream);
        localOutputStream.close();
        localBitmap1.recycle();
        localBitmap2.recycle();
        i = 1;
        return i;
      }
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        LogUtils.e(localIOException);
        int i = 0;
      }
    }
  }

  public static boolean create180RotatedBitmap(File paramFile1, File paramFile2, Bitmap.Config paramConfig)
  {
    AssertUtil.checkNull(paramFile1);
    AssertUtil.checkNull(paramFile2);
    AssertUtil.checkNull(paramConfig);
    try
    {
      if (FileUtil.doesExisted(paramFile1))
      {
        InputStream localInputStream = FileUtil.makeInputBuffered(new FileInputStream(paramFile1));
        Bitmap localBitmap1 = BitmapFactory.decodeStream(localInputStream);
        localInputStream.close();
        if (localBitmap1 != null)
        {
          Bitmap localBitmap2 = create180RotatedBitmap(localBitmap1, paramConfig);
          FileUtil.createNewFile(paramFile2);
          OutputStream localOutputStream = FileUtil.makeOutputBuffered(new FileOutputStream(paramFile2));
          Bitmap.CompressFormat localCompressFormat = Bitmap.CompressFormat.JPEG;
          boolean bool = localBitmap2.compress(localCompressFormat, 100, localOutputStream);
          localOutputStream.close();
          localBitmap1.recycle();
          localBitmap2.recycle();
          i = 1;
          return i;
        }
      }
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        LogUtils.e(localIOException);
        int i = 0;
      }
    }
  }

  public static boolean create180RotatedBitmap(String paramString, Bitmap.Config paramConfig)
  {
    AssertUtil.checkStringNullOrEmpty(paramString);
    AssertUtil.checkNull(paramConfig);
    return create180RotatedBitmap(new File(paramString), paramConfig);
  }

  public static boolean create180RotatedBitmap(String paramString1, String paramString2, Bitmap.Config paramConfig)
  {
    AssertUtil.checkStringNullOrEmpty(paramString1);
    AssertUtil.checkStringNullOrEmpty(paramString2);
    AssertUtil.checkNull(paramConfig);
    File localFile1 = new File(paramString1);
    File localFile2 = new File(paramString2);
    return create180RotatedBitmap(localFile1, localFile2, paramConfig);
  }

  public static byte[] create180RotatedBitmap(byte[] paramArrayOfByte, int paramInt1, int paramInt2, Bitmap.Config paramConfig)
  {
    AssertUtil.checkArrayNullOrEmpty(paramArrayOfByte);
    AssertUtil.checkNull(paramConfig);
    try
    {
      Bitmap localBitmap1 = BitmapFactory.decodeByteArray(paramArrayOfByte, paramInt1, paramInt2);
      if (localBitmap1 != null)
      {
        Bitmap localBitmap2 = create180RotatedBitmap(localBitmap1, paramConfig);
        ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream(524288);
        Bitmap.CompressFormat localCompressFormat = Bitmap.CompressFormat.JPEG;
        OutputStream localOutputStream = FileUtil.makeOutputBuffered(localByteArrayOutputStream);
        boolean bool = localBitmap2.compress(localCompressFormat, 100, localOutputStream);
        localBitmap1.recycle();
        localBitmap2.recycle();
        byte[] arrayOfByte1 = localByteArrayOutputStream.toByteArray();
        localByteArrayOutputStream.close();
        arrayOfByte2 = arrayOfByte1;
        return arrayOfByte2;
      }
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        LogUtils.e(localIOException);
        byte[] arrayOfByte2 = null;
      }
    }
  }

  public static Bitmap createLeftRotatedBitmap(Bitmap paramBitmap, Bitmap.Config paramConfig)
  {
    AssertUtil.checkNull(paramBitmap);
    AssertUtil.checkNull(paramConfig);
    Matrix localMatrix = new Matrix();
    boolean bool = localMatrix.postRotate(-90.0F);
    int i = paramBitmap.getWidth();
    int j = paramBitmap.getHeight();
    Bitmap localBitmap = paramBitmap;
    int k = 0;
    return Bitmap.createBitmap(localBitmap, 0, k, i, j, localMatrix, 1);
  }

  public static boolean createLeftRotatedBitmap(File paramFile, Bitmap.Config paramConfig)
  {
    AssertUtil.checkNull(paramFile);
    AssertUtil.checkNull(paramConfig);
    try
    {
      InputStream localInputStream = FileUtil.makeInputBuffered(new FileInputStream(paramFile));
      Bitmap localBitmap1 = BitmapFactory.decodeStream(localInputStream);
      localInputStream.close();
      if (localBitmap1 != null)
      {
        Bitmap localBitmap2 = createLeftRotatedBitmap(localBitmap1, paramConfig);
        FileUtil.createNewFile(paramFile);
        OutputStream localOutputStream = FileUtil.makeOutputBuffered(new FileOutputStream(paramFile));
        Bitmap.CompressFormat localCompressFormat = Bitmap.CompressFormat.JPEG;
        boolean bool = localBitmap2.compress(localCompressFormat, 100, localOutputStream);
        localOutputStream.close();
        localBitmap1.recycle();
        localBitmap2.recycle();
        i = 1;
        return i;
      }
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        LogUtils.e(localIOException);
        int i = 0;
      }
    }
  }

  public static boolean createLeftRotatedBitmap(File paramFile1, File paramFile2, Bitmap.Config paramConfig)
  {
    AssertUtil.checkNull(paramFile1);
    AssertUtil.checkNull(paramFile2);
    AssertUtil.checkNull(paramConfig);
    try
    {
      if (FileUtil.doesExisted(paramFile1))
      {
        InputStream localInputStream = FileUtil.makeInputBuffered(new FileInputStream(paramFile1));
        Bitmap localBitmap1 = BitmapFactory.decodeStream(localInputStream);
        localInputStream.close();
        if (localBitmap1 != null)
        {
          Bitmap localBitmap2 = createLeftRotatedBitmap(localBitmap1, paramConfig);
          FileUtil.createNewFile(paramFile2);
          OutputStream localOutputStream = FileUtil.makeOutputBuffered(new FileOutputStream(paramFile2));
          Bitmap.CompressFormat localCompressFormat = Bitmap.CompressFormat.JPEG;
          boolean bool = localBitmap2.compress(localCompressFormat, 100, localOutputStream);
          localOutputStream.close();
          localBitmap1.recycle();
          localBitmap2.recycle();
          i = 1;
          return i;
        }
      }
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        LogUtils.e(localIOException);
        int i = 0;
      }
    }
  }

  public static boolean createLeftRotatedBitmap(String paramString, Bitmap.Config paramConfig)
  {
    AssertUtil.checkStringNullOrEmpty(paramString);
    AssertUtil.checkNull(paramConfig);
    return createLeftRotatedBitmap(new File(paramString), paramConfig);
  }

  public static boolean createLeftRotatedBitmap(String paramString1, String paramString2, Bitmap.Config paramConfig)
  {
    AssertUtil.checkStringNullOrEmpty(paramString1);
    AssertUtil.checkStringNullOrEmpty(paramString2);
    AssertUtil.checkNull(paramConfig);
    File localFile1 = new File(paramString1);
    File localFile2 = new File(paramString2);
    return createLeftRotatedBitmap(localFile1, localFile2, paramConfig);
  }

  public static byte[] createLeftRotatedBitmap(byte[] paramArrayOfByte, int paramInt1, int paramInt2, Bitmap.Config paramConfig)
  {
    AssertUtil.checkArrayNullOrEmpty(paramArrayOfByte);
    AssertUtil.checkNull(paramConfig);
    try
    {
      Bitmap localBitmap1 = BitmapFactory.decodeByteArray(paramArrayOfByte, paramInt1, paramInt2);
      if (localBitmap1 != null)
      {
        Bitmap localBitmap2 = createLeftRotatedBitmap(localBitmap1, paramConfig);
        ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream(524288);
        Bitmap.CompressFormat localCompressFormat = Bitmap.CompressFormat.JPEG;
        OutputStream localOutputStream = FileUtil.makeOutputBuffered(localByteArrayOutputStream);
        boolean bool = localBitmap2.compress(localCompressFormat, 100, localOutputStream);
        localBitmap1.recycle();
        localBitmap2.recycle();
        byte[] arrayOfByte1 = localByteArrayOutputStream.toByteArray();
        localByteArrayOutputStream.close();
        arrayOfByte2 = arrayOfByte1;
        return arrayOfByte2;
      }
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        LogUtils.e(localIOException);
        byte[] arrayOfByte2 = null;
      }
    }
  }

  public static Bitmap createRightRotatedBitmap(Bitmap paramBitmap, Bitmap.Config paramConfig)
  {
    AssertUtil.checkNull(paramBitmap);
    AssertUtil.checkNull(paramConfig);
    Matrix localMatrix = new Matrix();
    boolean bool = localMatrix.postRotate(90.0F);
    int i = paramBitmap.getWidth();
    int j = paramBitmap.getHeight();
    Bitmap localBitmap = paramBitmap;
    int k = 0;
    return Bitmap.createBitmap(localBitmap, 0, k, i, j, localMatrix, 1);
  }

  public static boolean createRightRotatedBitmap(File paramFile, Bitmap.Config paramConfig)
  {
    AssertUtil.checkNull(paramFile);
    AssertUtil.checkNull(paramConfig);
    try
    {
      InputStream localInputStream = FileUtil.makeInputBuffered(new FileInputStream(paramFile));
      Bitmap localBitmap1 = BitmapFactory.decodeStream(localInputStream);
      localInputStream.close();
      if (localBitmap1 != null)
      {
        Bitmap localBitmap2 = createRightRotatedBitmap(localBitmap1, paramConfig);
        FileUtil.createNewFile(paramFile);
        OutputStream localOutputStream = FileUtil.makeOutputBuffered(new FileOutputStream(paramFile));
        Bitmap.CompressFormat localCompressFormat = Bitmap.CompressFormat.JPEG;
        boolean bool = localBitmap2.compress(localCompressFormat, 100, localOutputStream);
        localOutputStream.close();
        localBitmap1.recycle();
        localBitmap2.recycle();
        i = 1;
        return i;
      }
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        LogUtils.e(localIOException);
        int i = 0;
      }
    }
  }

  public static boolean createRightRotatedBitmap(File paramFile1, File paramFile2, Bitmap.Config paramConfig)
  {
    AssertUtil.checkNull(paramFile1);
    AssertUtil.checkNull(paramFile2);
    AssertUtil.checkNull(paramConfig);
    try
    {
      if (FileUtil.doesExisted(paramFile1))
      {
        InputStream localInputStream = FileUtil.makeInputBuffered(new FileInputStream(paramFile1));
        Bitmap localBitmap1 = BitmapFactory.decodeStream(localInputStream);
        localInputStream.close();
        if (localBitmap1 != null)
        {
          Bitmap localBitmap2 = createRightRotatedBitmap(localBitmap1, paramConfig);
          FileUtil.createNewFile(paramFile2);
          OutputStream localOutputStream = FileUtil.makeOutputBuffered(new FileOutputStream(paramFile2));
          Bitmap.CompressFormat localCompressFormat = Bitmap.CompressFormat.JPEG;
          boolean bool = localBitmap2.compress(localCompressFormat, 100, localOutputStream);
          localOutputStream.close();
          localBitmap1.recycle();
          localBitmap2.recycle();
          i = 1;
          return i;
        }
      }
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        LogUtils.e(localIOException);
        int i = 0;
      }
    }
  }

  public static boolean createRightRotatedBitmap(String paramString, Bitmap.Config paramConfig)
  {
    AssertUtil.checkStringNullOrEmpty(paramString);
    AssertUtil.checkNull(paramConfig);
    return createRightRotatedBitmap(new File(paramString), paramConfig);
  }

  public static boolean createRightRotatedBitmap(String paramString1, String paramString2, Bitmap.Config paramConfig)
  {
    AssertUtil.checkStringNullOrEmpty(paramString1);
    AssertUtil.checkStringNullOrEmpty(paramString2);
    AssertUtil.checkNull(paramConfig);
    File localFile1 = new File(paramString1);
    File localFile2 = new File(paramString2);
    return createRightRotatedBitmap(localFile1, localFile2, paramConfig);
  }

  public static byte[] createRightRotatedBitmap(byte[] paramArrayOfByte, int paramInt1, int paramInt2, Bitmap.Config paramConfig)
  {
    AssertUtil.checkArrayNullOrEmpty(paramArrayOfByte);
    AssertUtil.checkNull(paramConfig);
    try
    {
      Bitmap localBitmap1 = BitmapFactory.decodeByteArray(paramArrayOfByte, paramInt1, paramInt2);
      if (localBitmap1 != null)
      {
        Bitmap localBitmap2 = createRightRotatedBitmap(localBitmap1, paramConfig);
        ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream(524288);
        Bitmap.CompressFormat localCompressFormat = Bitmap.CompressFormat.JPEG;
        OutputStream localOutputStream = FileUtil.makeOutputBuffered(localByteArrayOutputStream);
        boolean bool = localBitmap2.compress(localCompressFormat, 100, localOutputStream);
        localBitmap1.recycle();
        localBitmap2.recycle();
        byte[] arrayOfByte1 = localByteArrayOutputStream.toByteArray();
        localByteArrayOutputStream.close();
        arrayOfByte2 = arrayOfByte1;
        return arrayOfByte2;
      }
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        LogUtils.e(localIOException);
        byte[] arrayOfByte2 = null;
      }
    }
  }

  public static Bitmap createScaledBitmap(Bitmap paramBitmap, int paramInt1, int paramInt2, Bitmap.Config paramConfig)
  {
    AssertUtil.checkNull(paramBitmap);
    int i = paramBitmap.getWidth();
    if (paramInt1 == i)
    {
      int j = paramBitmap.getHeight();
      if (paramInt2 != j);
    }
    for (Bitmap localBitmap = paramBitmap.copy(paramConfig, 1); ; localBitmap = Bitmap.createScaledBitmap(paramBitmap, paramInt1, paramInt2, 1))
      return localBitmap;
  }

  public static Bitmap createScaledBitmap_(Bitmap paramBitmap, int paramInt1, int paramInt2, Bitmap.Config paramConfig)
  {
    AssertUtil.checkNull(paramBitmap);
    AssertUtil.checkNull(paramConfig);
    label29: int m;
    int n;
    int[] arrayOfInt1;
    int[] arrayOfInt2;
    int[] arrayOfInt3;
    int i2;
    label109: label112: int i7;
    if (paramInt1 > 0)
    {
      int i = 1;
      AssertUtil.check(i);
      if (paramInt2 <= 0)
        break label190;
      int j = 1;
      AssertUtil.check(j);
      m = paramBitmap.getWidth();
      n = paramBitmap.getHeight();
      arrayOfInt1 = new int[m * n];
      Bitmap localBitmap = paramBitmap;
      int i1 = m;
      localBitmap.getPixels(arrayOfInt1, 0, m, 0, 0, i1, n);
      arrayOfInt2 = new int[paramInt2];
      arrayOfInt3 = new int[paramInt1];
      i2 = 0;
      paramBitmap = 0;
      i3 = 0;
      i4 = 0;
      if (n <= paramInt2)
        break label197;
      j = n;
      int i5 = 0;
      if (i5 <= j)
        break label203;
      i2 = 0;
      paramBitmap = 0;
      i3 = 0;
      i4 = 0;
      if (m <= paramInt1)
        break label269;
      j = m;
      label140: int i6 = 0;
      label143: if (i6 <= j)
        break label275;
      paramBitmap = new int[paramInt1 * paramInt2];
      i7 = 0;
      i2 = 0;
      n = 0;
    }
    label190: label197: label203: int i11;
    for (int i3 = -1; ; i3 = i11)
    {
      if (i2 >= paramInt2)
      {
        return Bitmap.createBitmap(paramBitmap, paramInt1, paramInt2, paramConfig);
        k = 0;
        break;
        k = 0;
        break label29;
        k = paramInt2;
        break label109;
        arrayOfInt2[paramBitmap] = i2;
        i3 += n;
        i4 += paramInt2;
        if (i3 > k)
        {
          i3 -= k;
          i2 += 1;
        }
        if (i4 > k)
        {
          i4 -= k;
          paramBitmap += 1;
        }
        i7 += 1;
        break label112;
        label269: k = paramInt1;
        break label140;
        label275: int i8 = (short)i2;
        arrayOfInt3[paramBitmap] = i8;
        i3 += m;
        i4 += paramInt1;
        if (i3 > k)
        {
          i3 -= k;
          i2 += 1;
        }
        if (i4 > k)
        {
          i4 -= k;
          paramBitmap += 1;
        }
        i7 += 1;
        break label143;
      }
      int i9 = arrayOfInt2[i2];
      if (i3 != i9)
        break label410;
      int i10 = i7 - paramInt1;
      System.arraycopy(paramBitmap, i10, paramBitmap, i7, paramInt1);
      i3 = n;
      i11 = arrayOfInt2[i2];
      i7 += paramInt1;
      i2 += 1;
      n = i3;
    }
    label410: int k = 0;
    int i4 = 0;
    while (true)
    {
      if (i4 >= paramInt1)
      {
        i3 = (arrayOfInt2[i2] - i3) * m + n;
        break;
      }
      int i12 = i7 + k;
      int i13 = arrayOfInt3[i4] + n;
      int i14 = arrayOfInt1[i13];
      paramBitmap[i12] = i14;
      k += 1;
      i4 += 1;
    }
  }

  public static Bitmap createZoomOutBitmap(File paramFile, int paramInt)
  {
    FileInputStream localFileInputStream = FileUtil.getFileInputStream(paramFile);
    return createZoomOutBitmap(new BufferedInputStream(localFileInputStream), paramInt);
  }

  public static Bitmap createZoomOutBitmap(InputStream paramInputStream, int paramInt)
  {
    AssertUtil.checkNull(paramInputStream);
    BitmapFactory.Options localOptions = new BitmapFactory.Options();
    paramInputStream = FileUtil.makeInputBuffered(paramInputStream);
    if (paramInt > 1)
      localOptions.inSampleSize = paramInt;
    Bitmap localBitmap = BitmapFactory.decodeStream(paramInputStream, null, localOptions);
    boolean bool = CleanUtils.closeStream(paramInputStream);
    return localBitmap;
  }

  public static Bitmap createZoomOutBitmap(String paramString, int paramInt)
  {
    return createZoomOutBitmap(new File(paramString), paramInt);
  }

  public static Bitmap createZoomOutBitmap(byte[] paramArrayOfByte, int paramInt1, int paramInt2, int paramInt3)
  {
    AssertUtil.checkArrayNullOrEmpty(paramArrayOfByte);
    BitmapFactory.Options localOptions = new BitmapFactory.Options();
    if (paramInt3 > 1)
      localOptions.inSampleSize = paramInt3;
    return BitmapFactory.decodeByteArray(paramArrayOfByte, paramInt1, paramInt2, localOptions);
  }

  public static Rect getMaxBound(long paramLong, Bitmap.Config paramConfig, int paramInt1, int paramInt2)
  {
    Rect localRect1 = new Rect(0, 0, paramInt1, paramInt2);
    Rect localRect2 = new Rect();
    return getMaxBound(paramLong, paramConfig, localRect1, localRect2);
  }

  public static Rect getMaxBound(long paramLong, Bitmap.Config paramConfig, Rect paramRect1, Rect paramRect2)
  {
    AssertUtil.checkNull(paramRect1);
    AssertUtil.checkNull(paramRect2);
    int i = 2;
    Bitmap.Config localConfig1 = Bitmap.Config.ALPHA_8;
    if (paramConfig == localConfig1)
      i = 1;
    while (true)
    {
      double d1 = paramRect1.width();
      double d2 = paramRect1.height();
      double d3 = paramLong * d1;
      double d4 = i * d2;
      double d5 = Math.sqrt(d3 / d4);
      double d6 = d5 * d2 / d1;
      int j = (int)d5;
      int k = (int)d6;
      paramRect2.set(0, 0, j, k);
      return paramRect2;
      Bitmap.Config localConfig2 = Bitmap.Config.ARGB_8888;
      if (paramConfig != localConfig2)
        continue;
      i = 4;
    }
  }

  public static boolean getZoomOutBitmapBound(File paramFile, int paramInt, Rect paramRect)
  {
    AssertUtil.checkNull(paramFile);
    AssertUtil.checkNull(paramRect);
    try
    {
      if (FileUtil.doesExisted(paramFile))
      {
        boolean bool1 = getZoomOutBitmapBound(FileUtil.makeInputBuffered(new FileInputStream(paramFile)), paramInt, paramRect);
        bool2 = bool1;
        return bool2;
      }
    }
    catch (FileNotFoundException localFileNotFoundException)
    {
      while (true)
      {
        LogUtils.e(localFileNotFoundException);
        boolean bool2 = false;
      }
    }
  }

  public static boolean getZoomOutBitmapBound(InputStream paramInputStream, int paramInt, Rect paramRect)
  {
    AssertUtil.checkNull(paramInputStream);
    AssertUtil.checkNull(paramRect);
    BitmapFactory.Options localOptions = new BitmapFactory.Options();
    paramInputStream = FileUtil.makeInputBuffered(paramInputStream);
    localOptions.inJustDecodeBounds = 1;
    if (paramInt > 1)
      localOptions.inSampleSize = paramInt;
    Bitmap localBitmap = BitmapFactory.decodeStream(paramInputStream, null, localOptions);
    boolean bool = CleanUtils.closeStream(paramInputStream);
    if ((localOptions.outWidth > 0) && (localOptions.outHeight > 0))
    {
      int i = localOptions.outWidth;
      int j = localOptions.outHeight;
      paramRect.set(0, 0, i, j);
    }
    for (int k = 1; ; k = 0)
      return k;
  }

  public static boolean getZoomOutBitmapBound(String paramString, int paramInt, Rect paramRect)
  {
    AssertUtil.checkStringNullOrEmpty(paramString);
    return getZoomOutBitmapBound(new File(paramString), paramInt, paramRect);
  }

  public static boolean getZoomOutBitmapBound(byte[] paramArrayOfByte, int paramInt1, int paramInt2, int paramInt3, Rect paramRect)
  {
    AssertUtil.checkArrayNullOrEmpty(paramArrayOfByte);
    AssertUtil.checkNull(paramRect);
    BitmapFactory.Options localOptions = new BitmapFactory.Options();
    localOptions.inJustDecodeBounds = 1;
    if (paramInt3 > 1)
      localOptions.inSampleSize = paramInt3;
    Bitmap localBitmap = BitmapFactory.decodeByteArray(paramArrayOfByte, paramInt1, paramInt2, localOptions);
    if ((localOptions.outWidth > 0) && (localOptions.outHeight > 0))
    {
      int i = localOptions.outWidth;
      int j = localOptions.outHeight;
      paramRect.set(0, 0, i, j);
    }
    for (int k = 1; ; k = 0)
      return k;
  }

  private static int getZoomOutRate(Rect paramRect1, Rect paramRect2)
  {
    int i = paramRect1.width();
    int j = paramRect1.height();
    int k = paramRect2.width();
    int m = paramRect2.height();
    if ((i < k) && (j < m));
    double d7;
    for (int n = 0; ; n = (int)Math.pow(2.0D, d7))
    {
      return n;
      int i1 = 0;
      int i2;
      int i3;
      do
      {
        i1 += 1;
        double d1 = i;
        double d2 = i1;
        double d3 = Math.pow(2.0D, d2);
        i2 = (int)(d1 / d3);
        double d4 = j;
        double d5 = i1;
        double d6 = Math.pow(2.0D, d5);
        i3 = (int)(d4 / d6);
      }
      while ((i2 >= k) || (i3 >= m));
      d7 = i1;
    }
  }

  public static int getZoomOutRate(File paramFile, Rect paramRect)
  {
    if ((paramFile != null) && (paramFile.exists()) && (paramFile.isFile()))
    {
      int i = 1;
      AssertUtil.check(i);
      if ((paramRect == null) || (paramRect.isEmpty()))
        break label67;
    }
    int k;
    label67: for (int j = 1; ; k = 0)
    {
      AssertUtil.check(j);
      FileInputStream localFileInputStream = FileUtil.getFileInputStream(paramFile);
      return getZoomOutRate(new BufferedInputStream(localFileInputStream), paramRect);
      k = 0;
      break;
    }
  }

  public static int getZoomOutRate(InputStream paramInputStream, Rect paramRect)
  {
    AssertUtil.checkNull(paramInputStream);
    Rect localRect;
    if ((paramRect != null) && (!paramRect.isEmpty()))
    {
      int i = 1;
      AssertUtil.check(i);
      localRect = new Rect();
      if (!getZoomOutBitmapBound(paramInputStream, 1, localRect))
        break label53;
    }
    label53: for (int j = getZoomOutRate(localRect, paramRect); ; j = 0)
    {
      return j;
      j = 0;
      break;
    }
  }

  public static int getZoomOutRate(String paramString, Rect paramRect)
  {
    return getZoomOutRate(new File(paramString), paramRect);
  }

  public static int getZoomOutRate(byte[] paramArrayOfByte, int paramInt1, int paramInt2, Rect paramRect)
  {
    AssertUtil.checkArrayNullOrEmpty(paramArrayOfByte);
    if ((paramRect != null) && (!paramRect.isEmpty()));
    int j;
    for (int i = 1; ; j = 0)
    {
      AssertUtil.check(i);
      ByteArrayInputStream localByteArrayInputStream = new ByteArrayInputStream(paramArrayOfByte, paramInt1, paramInt2);
      return getZoomOutRate(new BufferedInputStream(localByteArrayInputStream), paramRect);
    }
  }

  public static boolean isImage(File paramFile, Rect paramRect)
  {
    try
    {
      if (FileUtil.doesExisted(paramFile))
      {
        BitmapFactory.Options localOptions = new BitmapFactory.Options();
        localOptions.inJustDecodeBounds = 1;
        Bitmap localBitmap = BitmapFactory.decodeStream(new FileInputStream(paramFile), null, localOptions);
        if ((localOptions.outHeight > 0) && (localOptions.outWidth > 0))
        {
          if (paramRect != null)
          {
            int i = localOptions.outWidth;
            int j = localOptions.outHeight;
            paramRect.set(0, 0, i, j);
          }
          k = 1;
          return k;
        }
      }
    }
    catch (FileNotFoundException localFileNotFoundException)
    {
      while (true)
      {
        LogUtils.w("解析的图片资源不是可识别的格式");
        int k = 0;
      }
    }
  }

  public static boolean isImage(String paramString, Rect paramRect)
  {
    if (TextUtils.isEmpty(paramString));
    boolean bool;
    for (int i = 0; ; bool = isImage(new File(paramString), paramRect))
      return i;
  }

  public static boolean makeZoomOutBitmap(File paramFile, int paramInt)
  {
    return makeZoomOutBitmap(paramFile, paramFile, paramInt);
  }

  public static boolean makeZoomOutBitmap(File paramFile1, File paramFile2, int paramInt)
  {
    AssertUtil.checkNull(paramFile1);
    AssertUtil.checkNull(paramFile2);
    try
    {
      if (FileUtil.doesExisted(paramFile1))
      {
        Bitmap localBitmap = createZoomOutBitmap(FileUtil.makeInputBuffered(new FileInputStream(paramFile1)), paramInt);
        FileUtil.createNewFile(paramFile2);
        OutputStream localOutputStream = FileUtil.makeOutputBuffered(new FileOutputStream(paramFile2));
        Bitmap.CompressFormat localCompressFormat = Bitmap.CompressFormat.JPEG;
        boolean bool1 = localBitmap.compress(localCompressFormat, 100, localOutputStream);
        boolean bool2 = CleanUtils.closeStream(localOutputStream);
        bool3 = bool2;
        return bool3;
      }
    }
    catch (FileNotFoundException localFileNotFoundException)
    {
      while (true)
      {
        LogUtils.e(localFileNotFoundException);
        boolean bool3 = false;
      }
    }
  }

  public static boolean makeZoomOutBitmap(String paramString, int paramInt)
  {
    AssertUtil.checkStringNullOrEmpty(paramString);
    return makeZoomOutBitmap(new File(paramString), paramInt);
  }

  public static boolean makeZoomOutBitmap(String paramString1, String paramString2, int paramInt)
  {
    AssertUtil.checkStringNullOrEmpty(paramString1);
    AssertUtil.checkStringNullOrEmpty(paramString2);
    File localFile1 = new File(paramString1);
    File localFile2 = new File(paramString2);
    return makeZoomOutBitmap(localFile1, localFile2, paramInt);
  }

  public static boolean verifyBitmap(File paramFile)
  {
    try
    {
      boolean bool1 = verifyBitmap(new FileInputStream(paramFile));
      bool2 = bool1;
      return bool2;
    }
    catch (FileNotFoundException localFileNotFoundException)
    {
      while (true)
      {
        localFileNotFoundException.printStackTrace();
        boolean bool2 = false;
      }
    }
  }

  public static boolean verifyBitmap(InputStream paramInputStream)
  {
    BitmapFactory.Options localOptions = new BitmapFactory.Options();
    localOptions.inJustDecodeBounds = 1;
    if ((paramInputStream instanceof BufferedInputStream))
    {
      Bitmap localBitmap = BitmapFactory.decodeStream(paramInputStream, null, localOptions);
      if ((localOptions.outHeight <= 0) || (localOptions.outWidth <= 0))
        break label58;
    }
    label58: for (int i = 1; ; i = 0)
    {
      return i;
      paramInputStream = new BufferedInputStream(paramInputStream);
      break;
    }
  }

  public static boolean verifyBitmap(String paramString)
  {
    try
    {
      boolean bool1 = verifyBitmap(new FileInputStream(paramString));
      bool2 = bool1;
      return bool2;
    }
    catch (FileNotFoundException localFileNotFoundException)
    {
      while (true)
      {
        localFileNotFoundException.printStackTrace();
        boolean bool2 = false;
      }
    }
  }

  public static boolean verifyBitmap(byte[] paramArrayOfByte)
  {
    return verifyBitmap(new ByteArrayInputStream(paramArrayOfByte));
  }
}

/* Location:           D:\Program Files\eclipse\apktool-r01-3\新浪微博\classes.dex.dex2jar.jar
 * Qualified Name:     sudroid.android.graphics.BitmapUtils
 * JD-Core Version:    0.6.0
 */